 <!doctype html>
 <html lang="zh-CN">
 <head>
   <meta charset="UTF-8">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/common.css">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/main.css">
   <script type="text/javascript" src="__PUBLIC__/Js/Admin/jquery.min.js"></script>
   <script type="text/javascript" src="__PUBLIC__/Js/Admin/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="__PUBLIC__/Js/Admin/common.js"></script>
   
   <script type="text/javascript">
      $(function(){  
        $(".list_table").colResizable({
          liveDrag:true,
          gripInnerHtml:"<div class='grip'></div>", 
          draggingClass:"dragging", 
          minWidth:30
        }); 
        
        // 添加
        $("#btn_add").click(function(){
        	operate("__URL__/../User/addUser");
        });
        
        // 删除
        deleteById("__URL__/../User/deleteUser");
        
        // 密码修改的取消按钮
		$("#cancelBtn-pwd").click(function(){
			$(".password-info").css("display", "none");
		});
        
		// 密码修改的保存按钮
		$("#saveBtn-pwd").click(function(){
			var oldPassword =$("input[name='oldpassword']").val();
			// 密码
			var pwd = $("#new-password").val();
			// 确认密码
			var pwd_confirm = $("#form_pwd #password-confirm").val();
			if (oldPassword.length == 0){
				alert("请输入原密码！");
				return false;
			}
			$.ajax({
    			  url:"__URL__/../User/checkOldPwd",
    			  type:"POST",
				  async: false,
				  data: "oldpassword=" + $.trim(oldPassword) + "&userid=" + $("#username_alterPwd").val(),
				  dataType: "text",
				  success:function(respData) {
					   if(respData == "false"){
						   alert("输入的原密码不正确！");
					   } else if(respData == "true"){
						    // 密码的合法性检查
							if (pwd.length < 6){
								alert("密码必须大于6位！");
								return false;
							}
							if (pwd != pwd_confirm){
								alert("两次输入的密码不一致！");
								return false;
							}
						   $("#form_pwd").submit();
					   } else {
						   alert("未检索到该用户！");
					   }
				  },
				  error:function(){
				    	
				  }
    		   });
		});
     
      });
      
   		// 修改密码
	    function alterPwdInfo(username){
   			$("#username_alterPwd").val(username);
	    	$(".password-info").css("display", "block");
	    }
   </script>
   <title>景点管理</title>
 </head>
 <body>
  <div class="container">
     <div id="search_bar" class="mt10">
       <div class="box">
          <div class="box_border">
            <div class="box_top"><b class="pl5">搜索</b></div>
            <form class="box_center pt10 pb10" action="{:U('User/userList')}" method="post">
              <table class="form_table" style="width:100%;">
                <tr>
                  <td style="width:60px;">用户名</td>
                  <td style="width:15%;">
                  	<input type="text" name="username" class="input-text lh25" style="width:90%;" value="{$username}">
                  </td>
                  <td style="width:60px;">手机号码</td>
                  <td style="width:15%;">
                  	<input type="text" name="phone" class="input-text lh25" style="width:90%;" value="{$phone}">
                  </td>
                  <td>
                  	<input type="submit" name="button" class="btn btn82 btn_search" value="查询"> 
                  </td>
                </tr>
              </table>
            </form>
          </div>
        </div>
    </div>
    <div class="box_bottom pb5 pt5 pr10" style="border:1px solid #dadada;border-bottom:0;margin-top:10px;">
              <div class="search_bar_btn" style="margin-left:2px;">
                 <form method="post" id="operationForm">
                 	 <input type="hidden" id="del_id" name="idList"> 
	                 <!-- <input type="button" id="btn_add" class="btn btn82 btn_add"  value="添加"> -->
	                 <input type="button" id="btn_checkAll" class="btn btn82 btn_checked" value="全选"> 
       				 <input type="button" id="btn_unCheckAll" class="btn btn82 btn_nochecked" value="取消">
	       			 <input type="button" id="btn_del" class="btn btn82 btn_del" value="删除">
                 </form>
              </div>
            </div>
     <div id="table" class="mt10">
        <div class="box span10 oh">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                   <th width="5%">#</th>
                   <th width="10%">会员名</th>
                   <th width="10%">真实姓名</th>
                   <th width="10%">昵称</th>
                   <th width="5%">性别</th>
                   <th width="10%">手机号码</th>
                   <th width="8%">操作</th>
                </tr>
                <foreach name="userList" item="user">
                <tr class="tr">
                   <td class="td_center">
                   		<input type="checkbox" name="del_checkbox">
                   		<input type="hidden" value="{$user.id}">
                   </td>
                   <td class="td_center"><a href="{:U('User/editUser')}?id={$user.id}">{$user.user_code}</a></td>
                   <td class="td_center">{$user.real_name}</td>
                   <td class="td_center">{$user.username}</td>
                   <td class="td_center">
                   <if condition="$user.sex eq 2">
                     女
                   <else />
                     男
                   </if>
				   </td>
                   <td class="td_center">{$user.phone}</td>
                   <td class="td_center"><a href="javascript:alterPwdInfo('{$user.id}');" style="text-decoration:underline">修改密码</a></td>
                 </tr>
                 </foreach>
              </table>
        </div>
        <div class="pages"> {$page}</div>
     </div>
   	 <div class="password-info" style="display:none;position:fixed;top:0;left:0;background-color:rgba(0, 0, 0, 0.36);width:100%;height:100%;">
		 <form class="form-horizontal" id="form_pwd" role="form" action="{:U('User/alterPwd')}" method="post"
		 	 style="position:fixed;top:20%;left:20%; width:40%; height:250px;background-color:white;min-width:300px;">
		   <input type="hidden" name="userid" id="username_alterPwd" value="">
		   <table class="form_table pt15 pb15" style="width:100%">
             <tr >
              <td class="td_right"><label style="color:red;">*</label>原密码：</td>
              <td class="">
                  <input type="password" id="old-password" name="oldpassword" class="input-text lh30" size="30" value="{$attraction.name}">
              </td>
             </tr>
             <tr >
              <td class="td_right"><label style="color:red;">*</label>新密码：</td>
              <td class="">
                  <input type="password" id="new-password" name="password" class="input-text lh30" size="30" value="{$attraction.name}">
              </td>
             </tr>
             <tr >
              <td class="td_right"><label style="color:red;">*</label>确认密码：</td>
              <td class="">
                  <input type="password" id="password-confirm" class="input-text lh30" size="30" value="{$attraction.name}">
              </td>
             </tr>
             <tr>
               <td class="td_right">&nbsp;</td>
               <td class="">
                 <input type="button" name="save_button" id="saveBtn-pwd" class="btn btn82 btn_save2" value="保存"> 
                <input type="button" name="reset_button" id="cancelBtn-pwd" class="btn btn82 btn_res" value="取消">
               </td>
             </tr>
           </table>
		</form>
	  </div>
   </div> 
 </body>
 </html>
  